//
//  LoanGuideViewController.m
//  CreditHub
//
//  Created by chenglang on 2024/9/17.
//

#import "LoanGuideViewController.h"
#import "LoanGuideTableViewCell.h"
#import "LoanMterialsTitleCell.h"
#import "LoanMterialsStepCell.h"

@interface LoanGuideViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tabelView;

@end

@implementation LoanGuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.ch_title = @"Loan Guide";
    if(self.type != 2){
        self.ch_title = @"Loan Materials";
    }
    self.navBgImageView.hidden = NO;
    
    self.tabelView.delegate = self;
    self.tabelView.dataSource = self;
    
    [self.tabelView registerNib:[UINib nibWithNibName:@"LoanGuideTableViewCell" bundle:nil] forCellReuseIdentifier:@"LoanGuideTableViewCell"];
    [self.tabelView registerNib:[UINib nibWithNibName:@"LoanMterialsTitleCell" bundle:nil] forCellReuseIdentifier:@"LoanMterialsTitleCell"];
    [self.tabelView registerNib:[UINib nibWithNibName:@"LoanMterialsStepCell" bundle:nil] forCellReuseIdentifier:@"LoanMterialsStepCell"];
    self.tabelView.estimatedRowHeight = 44;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if(self.type == 2){
        return 4;
    }
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if(self.type == 2){
        if(indexPath.row==0){
            LoanMterialsTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LoanMterialsTitleCell"];
            
            return cell;
        }else{
            
            LoanMterialsStepCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LoanMterialsStepCell"];
            if(indexPath.row == 1){
                cell.labelTitle.text = @"The first step";
                cell.labelDetail.text = @"Log in to our product and click apply for a loan now.";
                cell.imgViewBg.image = [UIImage imageNamed:@"dkw_step1"];
            }else  if(indexPath.row == 2){
                cell.labelTitle.text = @"Step two";
                cell.labelDetail.text = @"Fill in your loan information and complete it Loan authentication";
                cell.imgViewBg.image = [UIImage imageNamed:@"dkw_step2"];
            }else  if(indexPath.row == 3){
                cell.labelTitle.text = @"Step Three";
                cell.labelDetail.text = @"Waiting for approval, loan acceptance (time 1-10 Minutes)";
                cell.imgViewBg.image = [UIImage imageNamed:@"dkw_step3"];
            }
            
            return cell;
        }
        
    }
    
    LoanGuideTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LoanGuideTableViewCell"];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if(self.type == 2){
        if(indexPath.row == 0){
            return 50;
        }
        return UITableViewAutomaticDimension;
    }
    return 720;
    
}


@end
